<script setup>
import sideBar from '@/view/menu/sideBar.vue'
import headerBar from '@/view/menu/headerBar.vue'
import { useBaseStore } from '@/stores/baseStore';
import { useRouter } from 'vue-router'
import { ElNotification } from 'element-plus'
import cartoonWatcher from '@/tool/CartoonWatcher/CartoonWatcher.vue'
import novelWatcher from '@/tool/NovelWatcher/NovelWatcher.vue'

const baseStore = useBaseStore();
const router = useRouter();

try {
	window.electronApi.receive('updateRoute', (path) => {
		console.log(path);
		router.push(path)
	});

	window.electronApi.receive('download-task-notifies', (title, msg) => {
		ElNotification({
			title: title,
			dangerouslyUseHTMLString: true,
			message: msg,
			position: 'top-left',
		})
	});

} catch {
	console.log("网页模式无法使用内置api");
}

</script>


<template>
	<cartoonWatcher v-if="baseStore.showContent === 'cartoonWatcher'" />
	<novelWatcher v-else-if="baseStore.showContent === 'novelWatcher'" />

	<el-container style="height: 100%;" v-else-if="baseStore.showContent === 'main'">
		<!-- 侧边栏 -->
		<el-aside width="120px" style="box-shadow: var(--el-box-shadow-lighter);">
			<sideBar />
		</el-aside>

		<el-container>
			<!-- 顶部菜单 -->
			<el-header style="padding: 0;height: 80px;">
				<headerBar />
			</el-header>

			<el-main style="background-color: #f7f7f7;">
				<router-view :key="baseStore.count" />
			</el-main>

		</el-container>

	</el-container>

</template>

<style scoped></style>
